package yuan.deng.service.impl;

import org.apache.ibatis.session.SqlSession;
import yuan.deng.domain.User;
import yuan.deng.mapper.UserMapper;
import yuan.deng.service.UserService;
import yuan.deng.utils.MapperUtils;

import java.util.List;

public class UserServiceImpl implements UserService {

    private UserMapper userMapper=(UserMapper) MapperUtils.getMapper(UserMapper.class);

    @Override
    public List<User> findAll() {
        return userMapper.findAll();
    }

    @Override
    public void userAdd(User user) {
        userMapper.userAdd(user);
    }

    @Override
    public void del(String id) {
        if (id!=null&&id.length()>0){
            String[] ids = id.split(",");
            for (int i = 0; i < ids.length; i++) {
                userMapper.del(ids[i]);
            }

        }
    }

    @Override
    public User findById(String id) {
        return userMapper.findById(id);
    }

    @Override
    public void update(User user) {
        userMapper.update(user);
    }
}
